<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core">

<h:head>
	<title>Gestion des stocks</title>
</h:head>
<h:body>

	<h1>Gestion des stocks derpizza</h1>
	
	<h:form>
	<h:dataTable value="#{frigo.listeIngredients}" var="ligne" binding="#{frigo.dataTable}" id="tableProduit">
		<h:column>
			<f:facet name="header">Produit</f:facet>
			<h:inputText value="#{ligne.nom}" >
				<f:ajax event="blur" listener="#{frigo.save}"/>
			</h:inputText>
		</h:column>
		<h:column>
			<f:facet name="header">Quantité</f:facet>
			<h:outputText value="#{ligne.quantite}" id="qte">
				<!--<f:ajax event="blur" listener="#{frigo.save}"/>-->
			</h:outputText>
			<h:commandButton action="#{ligne.plus}" value="+">
				<f:ajax render="qte"/>
			</h:commandButton>
			<h:commandButton action="#{ligne.moins}" value="-">
				<f:ajax render="qte"/>
			</h:commandButton>
		</h:column>
		<h:column>
			<f:facet name="header">Id</f:facet>
			<h:outputText value="#{ligne.id}" />
		</h:column>
		<h:column>
			<f:facet name="header">Suppr.</f:facet>
			<h:commandButton action="#{frigo.deleteIngredient}" value="Suppr.">	
				<f:ajax render="@form" />
			</h:commandButton>
		</h:column>
	</h:dataTable>
	<h:commandButton value="Nouvel ingrédient" action="#{frigo.nouvelIngredient}">
		<f:ajax render="tableProduit"/>
	</h:commandButton>
	</h:form>	
	
	
</h:body>
</html>